﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DietPlanning.Models;

namespace DietPlanning.Controllers
{
    public class UserDietController : Controller
    {
        //
        // GET: /UserDiet/
        private DailyFoodEntities db = new DailyFoodEntities();
        public ActionResult Index(int id)
        {
            List<Diet> diet = db.Diets.Where(o => o.UserID == id).ToList();
            List<DietDetail> dietDetail = new List<DietDetail>();
            foreach (Diet item in diet)
            {
                dietDetail.AddRange(db.DietDetails.Where(o => o.DietID == item.DietID));
            }
            UserDietModels UserDiet = new UserDietModels();
            UserDiet.Diet = diet;
            UserDiet.DietDetail = dietDetail;

            return View(UserDiet);
        }

    }
}
